//-----------------------------------------------------------------------
// <copyright file="NewsletterService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class NewsletterService
    {
        #region Newsletter

        public static void CreateNewsletter(Newsletter newsletter)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                newsletterDAO.CreateNewsletter(newsletter);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateNewsletterException, ex);
            }
        }        

        public static void UpdateNewsletter(Newsletter newsletter)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                newsletterDAO.UpdateNewsletter(newsletter);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateNewsletterException, ex);
            }
        }        

        public static void DeleteNewsletter(int newsletterId)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                newsletterDAO.DeleteNewsletter(newsletterId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteNewsletterException, ex);
            }
        }
        
        public static Newsletter GetNewsletter(int newsletterId)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                return newsletterDAO.GetNewsletter(newsletterId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetNewsletterException, ex);
            }
        }                

        public static NewsletterCollection GetNewsletterList(NewsletterColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                return newsletterDAO.GetNewsletterList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetNewsletterListException, ex);
            }
        }        

        public static NewsletterCollection GetNewsletterList(NewsletterColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                return newsletterDAO.GetNewsletterList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetNewsletterListException, ex);
            }
        }        

	    public static NewsletterCollection GetNewsletterListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                return newsletterDAO.GetNewsletterListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetNewsletterListException, ex);
            }
        }        

        public static NewsletterCollection GetNewsletterListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                NewsletterDAO newsletterDAO = new NewsletterDAO();
                return newsletterDAO.GetNewsletterListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetNewsletterListException, ex);
            }
        }        

        #endregion
    }
}